<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.model.Post"%>
<%@ page import="com.model.Admin"%>
<%@ page import="com.control.PostControl"%>
<%@ page import="com.control.AdminControl"%>
<%@ page import="com.util.PageResultSet"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>公告显示</title>
	</head>
	<body>
		<%
	    request.setCharacterEncoding("UTF-8");
	    String ToolBar = "";
	    int curPage = 1;
	%>
		<table width="98%" border="0" align="center">
			<tr>
				<td></td>
			</tr>
			<tr>
				<td></td>
			</tr>
			<tr>
				<td>
					<fieldset>
						<legend>
							公告列表
						</legend>
						<form action="post_show.jsp" name="form1" method="post">
							<table width="70%" border="0" align="center" cellspacing="0"
								cellpadding="0">
								<tr>
									<td height="20"></td>
								</tr>
								<tr>
									<td>
										<table border="1" width="99%" align="center" cellpadding="0"
											cellspacing="1" class="resultTable">
											<tr>
												<td width="1%" height="25" align="center" bgcolor="#D9F0FF">
													发布人
												</td>
												<td width="7%" height="25" align="center" bgcolor="#D9F0FF">
													内容
												</td>
												<td width="3%" height="25" align="center" bgcolor="#D9F0FF">
													发布时间
												</td>
												<td width="2%" height="25" align="center" bgcolor="#D9F0FF">
													操作
												</td>
								</tr>
								<%
									//request.setCharacterEncoding("UTF-8");
									//int pages = ParamUtil.getInt(request, "pages", 0);
									//int rowsPerPage = ParamUtil.getInt(request, "pageSize", 10);
									
										PostControl pc = new PostControl();
										ArrayList<Post> list = new ArrayList<Post>();
										list = pc.getPostInformation();
										if(request.getParameter("cur_page")!= null) {
											curPage = Integer.parseInt(request.getParameter("cur_page")); 
										}
										PageResultSet p = new PageResultSet(list,curPage);
										ArrayList<Post> nowlist = new ArrayList<Post>();
										nowlist = (ArrayList<Post>)p.getData();
										for(int i=0; i<nowlist.size(); i++) {
											Post post = nowlist.get(i);
									 %>
								 	<tr>
        								<td height="25" align="center"><%=post.getAdmin_name()%></td>
 										<td height="25" align="left"><%=post.getPost_content()%></td>
 										<td height="25" align="center"><%=post.getPost_time()%></td>
 		 								<td height="25" align="center"><a href="update_post.jsp?id=<%=post.getPost_id()%>">修改</a> | <a href="javascript:if(confirm('确认删除吗?'))window.location='delete_post.jsp?id=<%=post.getPost_id()%>'">删除</a></td>
 									</tr>
   									<%}
   										
										String fileName = "post_show.jsp";
										ToolBar = p.getToolBar(fileName);
										//System.out.println(ToolBar);
									%>
							</table>
							<%=ToolBar %>
							
							</td>
							</tr>
							</table>
						</form>
					</fieldset>
				</td>
			</tr>
		</table>
	</body>
</html>
